class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.integer :group_id
      t.string :email, :limit => 100, :null => false
      t.string :crypted_password, :null => false
      t.string :password_salt
      t.string :name, :limit => 45, :null => false
      t.string :address, :limit => 100
      t.integer :gg_uid
      t.string :phone, :limit => 11
      t.string :comment, :limit => 45
      t.float :saldo, :default => 0, :precision => 5, :scale => 2
      t.string :layout, :limit => 50, :default => "blue"
      t.boolean :logged_in, :default => false
      t.boolean :active
      t.integer :login_count, :null => false,   :default => 0
      t.integer :failed_login_count, :null => false,   :default => 0
      t.datetime :last_request_at
      t.datetime :last_login_at
      t.string :current_login_ip
      t.string :last_login_ip
      t.string :persistence_token
      t.string  :perishable_token, :default => "", :null => false
      t.timestamps
    end

    add_index :users, :perishable_token
    add_index :users, :email
    add_index :users, :persistence_token
    add_index :users, :last_request_at
  end

  def self.down
    drop_table :users
  end
end
